package src.main.java.com.pockergame;

import java.util.ArrayList;
import java.util.Collections;

public class PockerGame {
  public static void main(String[] args) {
    new PockerGame();
  }

  static ArrayList<String> list = new ArrayList<>();

  static {
    // 准备牌
    // "♠", "♥", "♦", "♣"
    String[] colors = { "B", "R", "Y", "F" };
    String[] nums = { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2" };

    for (String color : colors) {
      for (String num : nums) {
        list.add(color + num);
      }
    }

    list.add("大王");
    list.add("小王");

  }

  public PockerGame() {
    // 洗牌
    Collections.shuffle(list);
    System.out.println(list);
    // 发牌
    ArrayList<String> player1 = new ArrayList<>();
    ArrayList<String> player2 = new ArrayList<>();
    ArrayList<String> player3 = new ArrayList<>();
    ArrayList<String> lord = new ArrayList<>();

    for (int i = 0; i < list.size(); i++) {
      String pocker = list.get(i);
      if (i < 3) {
        lord.add(pocker);
      } else if (i % 3 == 0) {
        player1.add(pocker);
      } else if (i % 3 == 1) {
        player2.add(pocker);
      } else {
        player3.add(pocker);
      }
    }

    // 看牌
    lookPocker("底牌", lord);
    lookPocker("张三", player1);
    lookPocker("李四", player2);
    lookPocker("王五", player3);

  }

  /**
   * 看牌
   * 
   * @param player 玩家名字
   * @param list   玩家牌
   */
  public void lookPocker(String player, ArrayList<String> list) {
    for (String poker : list) {
      System.out.print(poker);
    }
    System.out.println();
  }

}
